package _06构造方法;

public class Person {

	// 1.属性(隐藏)
	private String name;
	private int age;
	private boolean married;
	
	// 如果我们定义了构造方法 编译器就不会自动创建
	// 如果没有定义构造方法 编译器会自动创建一个无参数的构造方法

	public Person(String name, int age, boolean married) {
		super();
		this.name = name;
		this.age = age;
		this.married = married;
	}

	public Person() {
		super();
	}

	// 2.提供set方法与get方法
	// setXXX 如果是布尔类型则是isXXX
	// getXXX
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		if (age >= 1 && age <= 150) {
			this.age = age;
		}
	}

	public boolean isMarried() {
		return married;
	}

	public void setMarried(boolean married) {
		this.married = married;
	}

}
